#! /usr/bin/make -f
%:
	dh $@

DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)

ifeq ($(DEB_HOST_ARCH),amd64)
MULTIARCH := i386
else
MULTIARCH :=
endif

ifeq (,$(filter-out amd64 i386,$(DEB_HOST_ARCH)))
SECURITYHOST := security.lingmo.com
SECURITYPATH := /lingmo
else
SECURITYHOST := ports.lingmo.com
SECURITYPATH := /lingmo-ports
endif

override_dh_installdebconf:
	dh_installdebconf
ifneq (,$(filter apt-mirror-setup,$(shell dh_listpackages)))
	echo >> debian/apt-mirror-setup/DEBIAN/templates
	po2debconf debian/apt-mirror-setup.templates-lingmo \
		>> debian/apt-mirror-setup/DEBIAN/templates
endif
	sed -i 's/@MULTIARCH@/$(MULTIARCH)/' \
		debian/apt-setup-udeb/DEBIAN/templates
	sed -i 's/@SECURITYHOST@/$(SECURITYHOST)/' \
		debian/apt-setup-udeb/DEBIAN/templates
	sed -i 's|@SECURITYPATH@|$(SECURITYPATH)|' \
		debian/apt-setup-udeb/DEBIAN/templates
